<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.contractCode" clearable placeholder="合同编号" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-input v-model="query.contractName" clearable placeholder="合同名称" style="width: 200px;" class="filter-item"/>
    <el-input v-model="query.customerName" clearable placeholder="所属客户" style="width: 200px;" class="filter-item" />
    <el-input v-model="query.contractItemName" clearable placeholder="合同类型" style="width: 200px;" class="filter-item" />
    <!-- <el-select v-model="query.type" clearable placeholder="类型" class="filter-item" style="width: 130px">
      <el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
    </el-select> -->
    <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
    <!-- 新增 -->
    <div style="display: inline-block;margin: 0px 2px;">
      <el-button
        v-permission="['ADMIN','TCUSTOMERCONTRACT_ALL','TCUSTOMERCONTRACT_CREATE']"
        class="filter-item"
        size="mini"
        type="primary"
        icon="el-icon-plus"
        @click="$refs.form.dialog = true">新增</el-button>
      <eForm ref="form" :is-add="true" :is-view="true"/>
    </div>
  </div>
</template>

<script>
import eForm from './form'
export default {
  components: { eForm },
  props: {
    query: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      queryTypeOptions: [
        { key: 'contractCode', display_name: '合同编号' },
        { key: 'contractName', display_name: '合同名称' },
        { key: 'customerName', display_name: '所属客户' },
        { key: 'contractItemName', display_name: '合同类型' }
      ]
    }
  },
  methods: {
    toQuery() {
      this.$parent.page = 0
      this.$parent.init()
    }
  }
}
</script>
